package com.corpgovernment.organization.util;

import com.corpgovernment.api.organization.model.passenger.MobilePhoneVo;
import com.ctrip.corp.obt.generic.utils.StringUtils;
import org.springframework.stereotype.Component;

/**
 * 人员信息处理
 * @author yuxing zhang
 * @date 2024/2/5 15:32
 */
@Component
public class EmployeeInfoHandleUtils {


    /**
     * 封装手机信息 拆分出国家码
     *
     * @param mobilePhone 手机号
     * @return 手机号 和 国家码
     */
    public MobilePhoneVo convertEmployeeMobilePhone(String mobilePhone) {
        MobilePhoneVo mobilePhoneVo = new MobilePhoneVo();
        if (StringUtils.isNotBlank(mobilePhone)) {
            String[] s = mobilePhone.split(" ");
            String countryCode = "+86";
            String phone = "";
            if (s.length == 2) {
                countryCode = s[0];
                phone = s[1];
            } else {
                phone = s[0];
            }
            mobilePhoneVo.setCountryCode(countryCode);
            mobilePhoneVo.setValue(phone);
        }
        return mobilePhoneVo;
    }



}
